﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _023_什么是类
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //声明Student 类型的stu
            Student stu;
            //实例化学生实例  默认构造器
            stu = new Student(1, "橙子") {};

            stu.Report();

            Type t =typeof(Student);
            Object  o =Activator.CreateInstance(t ,1,"橙子");
            //强转类型
            //Student stu2 = (Student)o;
            Student stu2 = o as Student;
            Console.WriteLine(o.GetType().Name);
        }
    }

    //类就相当于数据结构
    class Student
    {
        public Student(int id,string name)
        {
            this.ID = id;
            this.Name = name;
        }

        public Student()
        {
            ID = 2;
            Name = "梨梨";
        }

        //析构器
        //~ Student()
        //{
        //    Console.WriteLine("Bye Bye! Release the System resources"); 
        //}
        public int ID { get; set; }
        public string Name { get; set; }
        public void Report()
        {
            Console.WriteLine($"I am  #{ID} student,my name is {Name}");
        }

    }
}
